package ca.michaelmaguire.client.midlet;

import java.io.IOException;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class SampleMIDlet extends MIDlet {

	public SampleMIDlet() {
		iInstance = this;
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	protected void pauseApp() {
		// TODO Auto-generated method stub

	}

	protected void startApp() throws MIDletStateChangeException {

		Form helloForm = new Form("Hello, World!");
		ImageItem image;
		try {
			image = new ImageItem("Jake: ", Image
					.createImage("/SampleImage.jpg"), ImageItem.LAYOUT_CENTER,
					"Jake");
			helloForm.append(image);
		} catch (Exception e) {
			helloForm.append("Image loading error");
		}
		Display.getDisplay(this).setCurrent(helloForm);

		UpdatePingThread thread = new UpdatePingThread();
		thread.start();
	}

	public static MIDlet getMIDlet() {
		return iInstance;
	}

	private static MIDlet iInstance;
}
